import { generatePerson } from '@/utils'
import { create } from 'zustand'
import type { Props as SaleCardData } from '@/components/SaleDataCard'
type Store = {
    dataArray: any[],
    updateDataArray: (newDataArray: (dataArray: any[]) => any[]) => void
}
export const dataStore = create<Store>((set) => ({
    dataArray: generatePerson("order"),
    updateDataArray: (updater) => set(state => ({ dataArray: updater(state.dataArray) })),
}))

type Store2 = {
    orderCount: SaleCardData[],
    updateOrderCount: (newOrderCount: (orderCount: SaleCardData[]) => any[]) => void
}
export const orderCountStore = create<Store2>((set) => ({
    orderCount: [
        {
            valueColor: "#78cafe",
        },
        {
            title: "历年全国客户总数合计",
            value: 3175,
            valueColor: "#43e691"
        },
        {
            title: "历年全球设备总数合计",
            value: 4786,
            valueColor: "#f2b52d"
        },
        {
            // title: "报备订单总数",
            title: "全球报备总数合计",
            value: 30159,
            valueColor: "#cd3a3a"
        },
    ],
    updateOrderCount: (updater) => set(state => ({ orderCount: updater(state.orderCount) })),
}))